
%  Cmpti.m
%        A.P. Paplinski   25 May 1999 

% Initialisation of competitive learning
% generation of a 2-D pattern consisting of  m  clusters of
% normally distributed points

% clear

p = 2; m = 5 ;      % p inputs, m  outputs
clst = randn(p, m); %  cluster centroids

Nk = 100;       % points per cluster
N = m*Nk ;      % total number of points

sprd = 0.2 ;      % a relative spread of the Gaussian "blob"
X = zeros(p,N+m); % X is  p by m+N input data matrix
wNk = ones(1, Nk);

for k = 1:m
  xc = clst(:,k) ;
  X(:,(1+(k-1)*Nk):(k*Nk))=sprd*randn(p,Nk)+xc(:,wNk) ;
end

[xc k] = sort(rand(1,N+m));
X = X(:, k) ;      % input data is shuffled randomly
winit = X(:,1:m)'; % Initial values of weights
X = X(:,m+1:N+m);

%figure(1), clf reset
%plot(X(1, :), X(2, :), 'g.', winit(:, 1), winit(:, 2), 'bx', ...
%  clst(1, :), clst(2, :), 'ro' ), grid, title('Input data')


